package com.bw.shop_2302.user

import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.bumptech.glide.Glide
import com.bw.base.mvvm.BaseActivity
import com.bw.shop_2302.R
import com.bw.shop_2302.UserActivity2
import com.bw.shop_2302.databinding.ActivityUserBinding

@Route(path = "/app/User/UserActivity")
class UserActivity : BaseActivity<ActivityUserBinding,UserViewModel>(){

    override fun initView() {

        viewModel.user()

        binding.ivUpdate.setOnClickListener {


            startActivity(Intent(this,UserActivity2::class.java))


        }

    }

    override fun initData() {

        viewModel.usersuccess.observe(this){

            if(it.code==200){

                binding.user=it.data
                binding.tvUsername.text=it.data.nickname
                binding.tvUserphone.text=it.data.phone
                Glide.with(this).load(it.data.avatar).circleCrop().into(binding.ivUsericon)

            }

        }
    }

    override fun getviewmodel(): Class<UserViewModel> = UserViewModel::class.java

    override fun getLayoutID(): Int = R.layout.activity_user

}